<template>
	<view>

		

		<!-- 手动添加弹窗 -->
		
			<form @submit="formSubmit" >
				<view class="addPop_box">
					<view class="handleList_box">
						<view class="handleList_con">
							<view class="handleLabel handleLabelLong">工友姓名：</view>
							<view class="handleList">
								<view class="pickerCon">
									<input name="name" v-model="formData.name" placeholder="请输入工友姓名"
										placeholder-class="placeholderColor">
								</view>
							</view>
						</view>
						<view class="handleList_con">
							<view class="handleLabel handleLabelLong">上班工资：</view>
							<view class="handleList">
								<view class="pickerCon">
									<input type="digit" name="salary" v-model="formData.salary" placeholder="请输入上班工资"
										placeholder-class="placeholderColor">
									<text>元/工</text>
								</view>
							</view>
						</view>
						<view class="handleList_con">
							<view class="handleLabel handleLabelLong">加班工资：</view>
							<view class="handleList">
								<view class="pickerCon">
									<input type="digit" name="overtime_salary" v-model="formData.overtime_salary"
										placeholder="请输入加班工资" placeholder-class="placeholderColor">
									<text>元/小时</text>
								</view>
							</view>
						</view>
					</view>
					<view class="handlePost_con">
						<button class="completeBtn" form-type="submit" hover-class="none">添加</button>
					</view>
				</view>
			</form>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				// 默认工地信息
				defaultWorksite: JSON.parse(uni.getStorageSync('defaultWorksite')),

				// 手动添加弹窗
				addShow: false,
				// 表单
				formData: {
					name: '',
					salary: '',
					overtime_salary: '',
				},
			}
		},
		
		onShow() {},
		methods: {
			// 提交
			formSubmit(e) {
				// console.log(e);
				var _this = this;
				var formData = e.detail.value;

				if (!formData.name) {
					uni.showModal({
						content: '姓名不能为空',
						showCancel: false,
					})
					return;
				}
				_this.formData = formData;
				_this.$u.throttle(_this.submitForm, 3000);
			},

			// 提交接口
			submitForm() {
				var _this = this;
				_this.$u.post('/api/project.member/add_do', {
					project_id: _this.defaultWorksite.project_id,
					name: _this.formData.name,
					salary: _this.formData.salary,
					overtime_salary: _this.formData.overtime_salary,
					mobile:'',
					work_class: '',
					img: '',
				}).then(res => {
					console.log(res);
					uni.showModal({
						title: '提示',
						content: res.msg,
						cancelText: '返回',
						confirmText: '继续添加',
						success: function(res) {
							if (res.confirm) {
								// console.log('用户点击确定');
								// 清空数据
								// uni.navigateBack({
								// 	delta: 1
								// })
								_this.formData = {
									name: '',
									salary: '',
									mobile: '',
								}
								
							} else if (res.cancel) {
								// console.log('用户点击取消');
								
								uni.redirectTo({
									url:'/pages/worker/workerHome'
								})
								
								
							}
						}
					});
				}).catch(res => {
					console.log(res);
				})
			},
			
			
			
			

		}
	}
</script>

<style>
	page {
		background-color: #fff;
	}
</style>
<style scoped lang="scss">
	/* 菜单 */
	.messageMenu_box {
		padding: 0 30rpx;
	}

	.menuItem {
		padding: 30rpx 0;
		border-bottom: 1rpx solid #eee;
		overflow: hidden;
		display: flex;
		justify-content: space-between;
		align-items: center;
	}

	.menuItem:last-child .menuCon {
		border-bottom: 0;
	}

	.menuItem image {
		width: 100rpx;
		height: 100rpx;
	}

	.menuCon {
		flex: 2;
		padding: 40rpx 0;
		margin-left: 20rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;
	}

	.menuItem .menuTit {
		font-size: 32rpx;
		font-weight: bold;
		color: $uni-color;
	}

	.menuItem .menuDesc {
		font-size: 24rpx;
		color: $uni-color-text;
	}

	// 手动添加弹窗
	.addPop_box {
		padding: 0 30rpx;
	}

	.addPop_tit {
		padding: 40rpx 0;
		font-size: 32rpx;
		font-weight: bold;
		color: $uni-color;
		text-align: center;
		overflow: hidden;
	}

	.handleList_box {
		padding: 15rpx 0;
	}
	
	.handlePost_con {
		padding: 0 30rpx 0 0;
		border: 0;
		position: fixed;
		bottom: 50rpx;
		left: 0rpx;
	}
	.completeBtn{
		margin-left: 30rpx;
		flex: 1;
		
	}
	.completeBtn:last-child{
		margin-right: 0;
	}
	
	.pickerCon input{
		width: 350rpx;
	}
	.handleList_con .pickerCon {
		padding: 30rpx 30rpx;
	}
</style>
